package com.atguigu.bigdata.scala.mytest.chapter07

object Test_eq extends App {
  /**
   * 基本类型
   */
  val j1 = 234.toString
  val j2 = 234.toString
  println(j1 eq j2) // 引用
  println(j1 equals j2) // 值
  println(j1 == j2) // 当比较的对象为null时等价eq，否则等价equals
  println("---------------------------")
  /**
   * 集合类型
   */
  val a1 = Array("x", "y")
  val a2 = Array("x", "y")
  println(a1 equals a2)
  println(a1 eq a2)
  println(a1 == a2)
  println(a1 sameElements a2)
  val m1 = Map(1->"x", 2->"y")
  val m2 = Map(1->"x", 2->"y")
  println(m1 sameElements m2)
  val m3 = Map(1->"x", 2->"z")
  println(m1 sameElements m3)
  println("===========================")
  /**
   * 引用类型
   */
  val b1 = Bread("BreadTalk", 50)
  val b2 = Bread("BreadTalk", 50)
  println(b1 eq b2) // 引用
  println(b1 equals b2) // 值
  println(b1 == b2) // 当比较的对象为null时等价eq，否则等价equals
}

class Bread(str: String, i: Int){

}
object Bread{
  def apply(str: String, i: Int): Bread = new Bread(str, i)
}
